<ix-modal-header
  [requiredRoles]="requiredRoles"
  [title]="title"
  [loading]="isLoading()"
></ix-modal-header>

<mat-card>
  <mat-card-content>
    <form class="ix-form-container" [formGroup]="form" (submit)="onSubmit()">
      <ix-fieldset
        [title]="'Snapshot Time {time}' | translate: { time: data?.snapshot?.time?.$date| date: 'medium' }"
      ></ix-fieldset>

      <ix-fieldset [title]="'Remote' | translate">
        <ix-radio-group
          formControlName="includeExclude"
          [label]="'Include/Exclude' | translate"
          [tooltip]="helptext.tooltips.includeExclude | translate"
          [options]="includeExcludeOptions$"
        ></ix-radio-group>

        @if (isExcludePathsSelected) {
          <ix-explorer
            formControlName="excludedPaths"
            [required]="true"
            [tooltip]="helptext.tooltips.excludedPaths | translate"
            [label]="'Excluded Paths' | translate"
            [nodeProvider]="snapshotNodeProvider"
            [rootNodes]="data?.backup.absolute_paths ? [rootDatasetNode] : [slashRootNode]"
            [multiple]="true"
          ></ix-explorer>
        }

        @if (isExcludeByPatternSelected) {
          <ix-input
            formControlName="excludePattern"
            [tooltip]="helptext.tooltips.pattern | translate"
            [label]="'Pattern' | translate"
            [required]="true"
          ></ix-input>
        }

        @if (isIncludeFromSubfolderSelected) {
          <ix-explorer
            formControlName="subFolder"
            [required]="true"
            [label]="'Subfolder' | translate"
            [nodeProvider]="snapshotNodeProvider"
            [rootNodes]="data?.backup.absolute_paths ? [rootDatasetNode] : [slashRootNode]"
            [tooltip]="helptext.tooltips.subFolder | translate"
          ></ix-explorer>
        }

        @if (isIncludeFromSubfolderSelected) {
          <ix-explorer
            formControlName="includedPaths"
            [rootNodes]="includedPathsRootNodes"
            [label]="'Included Paths' | translate"
            [nodeProvider]="snapshotNodeProvider"
            [tooltip]="helptext.tooltips.includedPaths | translate"
            [multiple]="true"
          ></ix-explorer>
        }
      </ix-fieldset>

      <ix-fieldset [title]="'Local' | translate">
        <ix-explorer
          formControlName="target"
          [required]="true"
          [label]="'Target' | translate"
          [nodeProvider]="fileNodeProvider"
          [tooltip]="helptext.tooltips.target | translate"
          [canCreateDataset]="true"
          [createDatasetProps]="createDatasetProps"
        ></ix-explorer>
      </ix-fieldset>

      <ix-form-actions>
        <button
          *ixRequiresRoles="requiredRoles"
          mat-button
          type="submit"
          color="primary"
          ixTest="save"
          [disabled]="form.invalid || isLoading()"
        >
          {{ 'Save' | translate }}
        </button>
      </ix-form-actions>
    </form>
  </mat-card-content>
</mat-card>
